#![allow(dead_code, mutable_transmutes, non_camel_case_types, non_snake_case, non_upper_case_globals, unused_assignments, unused_mut)]
#![feature(extern_types)]
extern crate libc;
use primary::alloc_testing::*;
use primary::queue::*;
use primary::compare_pointer::*;
use primary::compare_string::*;
use primary::compare_int::*;
use primary::hash_pointer::*;
use primary::hash_string::*;
use primary::hash_int::*;
extern "C" {
    pub type _Queue;
    fn __assert_fail(
        __assertion: *const libc::c_char,
        __file: *const libc::c_char,
        __line: libc::c_uint,
        __function: *const libc::c_char,
    ) -> !;
                                        }
#[no_mangle]
pub static mut variable1: libc::c_int = 0;
#[no_mangle]
pub static mut variable2: libc::c_int = 0;
#[no_mangle]
pub static mut variable3: libc::c_int = 0;
#[no_mangle]
pub static mut variable4: libc::c_int = 0;
#[no_mangle]
pub extern "C" fn generate_queue() -> *mut Queue {
    let mut queue: *mut Queue = std::ptr::null_mut();
    let mut i: libc::c_int = 0;

    queue = queue_new();
    let queue_box = unsafe { Box::from_raw(queue) };

    while i < 1000 {
        queue_push_head(queue, unsafe { &mut variable1 as *mut libc::c_int as QueueValue });
        queue_push_head(queue, unsafe { &mut variable2 as *mut libc::c_int as QueueValue });
        queue_push_head(queue, unsafe { &mut variable3 as *mut libc::c_int as QueueValue });
        queue_push_head(queue, unsafe { &mut variable4 as *mut libc::c_int as QueueValue });
        i += 1;
    }

    queue = Box::into_raw(queue_box);
    queue
}
#[no_mangle]
pub extern "C" fn test_queue_new_free() {
    let mut i: libc::c_int = 0;
    let mut queue: *mut Queue = std::ptr::null_mut();

    queue = queue_new();
    let queue_box = unsafe { Box::from_raw(queue) };
    queue_free(queue);
    queue = queue_new();
    queue = Box::into_raw(queue_box);

    i = 0;
    while i < 1000 {
        queue_push_head(queue, unsafe { &mut variable1 as *mut libc::c_int as QueueValue });
        i += 1;
    }

    queue_free(queue);
}
#[no_mangle]
pub extern "C" fn test_queue_push_head() {
    let mut queue: *mut Queue = std::ptr::null_mut();
    let mut i: libc::c_int = 0;

    queue = queue_new();
    let queue_box = unsafe { Box::from_raw(queue) };

    i = 0;
    while i < 1000 {
        queue_push_head(queue, unsafe { &mut variable1 as *mut libc::c_int as QueueValue });
        queue_push_head(queue, unsafe { &mut variable2 as *mut libc::c_int as QueueValue });
        queue_push_head(queue, unsafe { &mut variable3 as *mut libc::c_int as QueueValue });
        queue_push_head(queue, unsafe { &mut variable4 as *mut libc::c_int as QueueValue });
        i += 1;
    }

    assert_eq!(queue_is_empty(queue), 0, "Queue should not be empty");
    assert_eq!(queue_pop_tail(queue), unsafe { &mut variable1 as *mut libc::c_int as QueueValue }, "Expected variable1");
    assert_eq!(queue_pop_tail(queue), unsafe { &mut variable2 as *mut libc::c_int as QueueValue }, "Expected variable2");
    assert_eq!(queue_pop_tail(queue), unsafe { &mut variable3 as *mut libc::c_int as QueueValue }, "Expected variable3");
    assert_eq!(queue_pop_tail(queue), unsafe { &mut variable4 as *mut libc::c_int as QueueValue }, "Expected variable4");
    assert_eq!(queue_pop_head(queue), unsafe { &mut variable4 as *mut libc::c_int as QueueValue }, "Expected variable4");
    assert_eq!(queue_pop_head(queue), unsafe { &mut variable3 as *mut libc::c_int as QueueValue }, "Expected variable3");
    assert_eq!(queue_pop_head(queue), unsafe { &mut variable2 as *mut libc::c_int as QueueValue }, "Expected variable2");
    assert_eq!(queue_pop_head(queue), unsafe { &mut variable1 as *mut libc::c_int as QueueValue }, "Expected variable1");

    queue = Box::into_raw(queue_box);
    queue_free(queue);
}
#[no_mangle]
pub extern "C" fn test_queue_pop_head() {
    let mut queue: *mut Queue = std::ptr::null_mut();
    queue = queue_new();
    let queue_box = unsafe { Box::from_raw(queue) };
    assert!(queue_pop_head(queue).is_null(), "queue_pop_head(queue) == NULL");
    queue = Box::into_raw(queue_box);
    queue_free(queue);

    queue = generate_queue();
    let queue_box = unsafe { Box::from_raw(queue) };
    while queue_is_empty(queue) == 0 {
        assert_eq!(queue_pop_head(queue), unsafe { &mut variable4 as *mut libc::c_int as QueueValue }, "queue_pop_head(queue) == &variable4");
        assert_eq!(queue_pop_head(queue), unsafe { &mut variable3 as *mut libc::c_int as QueueValue }, "queue_pop_head(queue) == &variable3");
        assert_eq!(queue_pop_head(queue), unsafe { &mut variable2 as *mut libc::c_int as QueueValue }, "queue_pop_head(queue) == &variable2");
        assert_eq!(queue_pop_head(queue), unsafe { &mut variable1 as *mut libc::c_int as QueueValue }, "queue_pop_head(queue) == &variable1");
    }
    assert!(queue_pop_head(queue).is_null(), "queue_pop_head(queue) == NULL");
    queue = Box::into_raw(queue_box);
    queue_free(queue);
}
#[no_mangle]
pub extern "C" fn test_queue_peek_head() {
    let mut queue: *mut Queue = std::ptr::null_mut();
    queue = queue_new();
    let queue_box = unsafe { Box::from_raw(queue) };
    assert!(queue_peek_head(queue).is_null(), "queue_peek_head(queue) == NULL");
    queue = Box::into_raw(queue_box);
    queue_free(queue);

    queue = generate_queue();
    let queue_box = unsafe { Box::from_raw(queue) };

    while queue_is_empty(queue) == 0 {
        assert_eq!(queue_peek_head(queue), unsafe { &mut variable4 as *mut libc::c_int as QueueValue }, "queue_peek_head(queue) == &variable4");
        assert_eq!(queue_pop_head(queue), unsafe { &mut variable4 as *mut libc::c_int as QueueValue }, "queue_pop_head(queue) == &variable4");
        assert_eq!(queue_peek_head(queue), unsafe { &mut variable3 as *mut libc::c_int as QueueValue }, "queue_peek_head(queue) == &variable3");
        assert_eq!(queue_pop_head(queue), unsafe { &mut variable3 as *mut libc::c_int as QueueValue }, "queue_pop_head(queue) == &variable3");
        assert_eq!(queue_peek_head(queue), unsafe { &mut variable2 as *mut libc::c_int as QueueValue }, "queue_peek_head(queue) == &variable2");
        assert_eq!(queue_pop_head(queue), unsafe { &mut variable2 as *mut libc::c_int as QueueValue }, "queue_pop_head(queue) == &variable2");
        assert_eq!(queue_peek_head(queue), unsafe { &mut variable1 as *mut libc::c_int as QueueValue }, "queue_peek_head(queue) == &variable1");
        assert_eq!(queue_pop_head(queue), unsafe { &mut variable1 as *mut libc::c_int as QueueValue }, "queue_pop_head(queue) == &variable1");
    }

    assert!(queue_peek_head(queue).is_null(), "queue_peek_head(queue) == NULL");
    queue = Box::into_raw(queue_box);
    queue_free(queue);
}
#[no_mangle]
pub extern "C" fn test_queue_push_tail() {
    let mut queue: *mut Queue = std::ptr::null_mut();
    let mut i: libc::c_int = 0;

    queue = queue_new();
    let queue_box = unsafe { Box::from_raw(queue) };

    i = 0;
    while i < 1000 {
        queue_push_tail(queue, unsafe { &mut variable1 as *mut libc::c_int as QueueValue });
        queue_push_tail(queue, unsafe { &mut variable2 as *mut libc::c_int as QueueValue });
        queue_push_tail(queue, unsafe { &mut variable3 as *mut libc::c_int as QueueValue });
        queue_push_tail(queue, unsafe { &mut variable4 as *mut libc::c_int as QueueValue });
        i += 1;
    }

    assert_eq!(queue_is_empty(queue), 0, "Queue should not be empty");
    assert_eq!(queue_pop_head(queue), unsafe { &mut variable1 as *mut libc::c_int as QueueValue }, "Expected variable1");
    assert_eq!(queue_pop_head(queue), unsafe { &mut variable2 as *mut libc::c_int as QueueValue }, "Expected variable2");
    assert_eq!(queue_pop_head(queue), unsafe { &mut variable3 as *mut libc::c_int as QueueValue }, "Expected variable3");
    assert_eq!(queue_pop_head(queue), unsafe { &mut variable4 as *mut libc::c_int as QueueValue }, "Expected variable4");
    assert_eq!(queue_pop_tail(queue), unsafe { &mut variable4 as *mut libc::c_int as QueueValue }, "Expected variable4");
    assert_eq!(queue_pop_tail(queue), unsafe { &mut variable3 as *mut libc::c_int as QueueValue }, "Expected variable3");
    assert_eq!(queue_pop_tail(queue), unsafe { &mut variable2 as *mut libc::c_int as QueueValue }, "Expected variable2");
    assert_eq!(queue_pop_tail(queue), unsafe { &mut variable1 as *mut libc::c_int as QueueValue }, "Expected variable1");

    queue = Box::into_raw(queue_box);
    queue_free(queue);
}
#[no_mangle]
pub extern "C" fn test_queue_pop_tail() {
    let mut queue: *mut Queue = std::ptr::null_mut();
    queue = queue_new();
    let queue_box = unsafe { Box::from_raw(queue) };
    assert!(queue_pop_tail(queue).is_null(), "queue_pop_tail(queue) == NULL");
    queue = Box::into_raw(queue_box);
    queue_free(queue);

    queue = generate_queue();
    let queue_box = unsafe { Box::from_raw(queue) };
    while queue_is_empty(queue) == 0 {
        assert_eq!(queue_pop_tail(queue), unsafe { &mut variable1 as *mut libc::c_int as QueueValue }, "queue_pop_tail(queue) == &variable1");
        assert_eq!(queue_pop_tail(queue), unsafe { &mut variable2 as *mut libc::c_int as QueueValue }, "queue_pop_tail(queue) == &variable2");
        assert_eq!(queue_pop_tail(queue), unsafe { &mut variable3 as *mut libc::c_int as QueueValue }, "queue_pop_tail(queue) == &variable3");
        assert_eq!(queue_pop_tail(queue), unsafe { &mut variable4 as *mut libc::c_int as QueueValue }, "queue_pop_tail(queue) == &variable4");
    }
    assert!(queue_pop_tail(queue).is_null(), "queue_pop_tail(queue) == NULL");
    queue = Box::into_raw(queue_box);
    queue_free(queue);
}
#[no_mangle]
pub extern "C" fn test_queue_peek_tail() {
    let mut queue: *mut Queue = std::ptr::null_mut();
    queue = queue_new();
    if (queue_peek_tail(queue)).is_null() {} else {
        assert!(queue_peek_tail(queue).is_null(), "queue_peek_tail(queue) == NULL");
    };
    queue_free(queue);
    queue = generate_queue();
    while queue_is_empty(queue) == 0 {
        if queue_peek_tail(queue) == unsafe { &mut variable1 as *mut libc::c_int as QueueValue }
        {} else {
            assert_eq!(queue_peek_tail(queue), unsafe { &mut variable1 as *mut libc::c_int as QueueValue }, "queue_peek_tail(queue) == &variable1");
        };
        if queue_pop_tail(queue) == unsafe { &mut variable1 as *mut libc::c_int as QueueValue }
        {} else {
            assert_eq!(queue_pop_tail(queue), unsafe { &mut variable1 as *mut libc::c_int as QueueValue }, "queue_pop_tail(queue) == &variable1");
        };
        if queue_peek_tail(queue) == unsafe { &mut variable2 as *mut libc::c_int as QueueValue }
        {} else {
            assert_eq!(queue_peek_tail(queue), unsafe { &mut variable2 as *mut libc::c_int as QueueValue }, "queue_peek_tail(queue) == &variable2");
        };
        if queue_pop_tail(queue) == unsafe { &mut variable2 as *mut libc::c_int as QueueValue }
        {} else {
            assert_eq!(queue_pop_tail(queue), unsafe { &mut variable2 as *mut libc::c_int as QueueValue }, "queue_pop_tail(queue) == &variable2");
        };
        if queue_peek_tail(queue) == unsafe { &mut variable3 as *mut libc::c_int as QueueValue }
        {} else {
            assert_eq!(queue_peek_tail(queue), unsafe { &mut variable3 as *mut libc::c_int as QueueValue }, "queue_peek_tail(queue) == &variable3");
        };
        if queue_pop_tail(queue) == unsafe { &mut variable3 as *mut libc::c_int as QueueValue }
        {} else {
            assert_eq!(queue_pop_tail(queue), unsafe { &mut variable3 as *mut libc::c_int as QueueValue }, "queue_pop_tail(queue) == &variable3");
        };
        if queue_peek_tail(queue) == unsafe { &mut variable4 as *mut libc::c_int as QueueValue }
        {} else {
            assert_eq!(queue_peek_tail(queue), unsafe { &mut variable4 as *mut libc::c_int as QueueValue }, "queue_peek_tail(queue) == &variable4");
        };
        if queue_pop_tail(queue) == unsafe { &mut variable4 as *mut libc::c_int as QueueValue }
        {} else {
            assert_eq!(queue_pop_tail(queue), unsafe { &mut variable4 as *mut libc::c_int as QueueValue }, "queue_pop_tail(queue) == &variable4");
        };
    }
    if (queue_peek_tail(queue)).is_null() {} else {
        assert!(queue_peek_tail(queue).is_null(), "queue_peek_tail(queue) == NULL");
    };
    queue_free(queue);
}
#[no_mangle]
pub extern "C" fn test_queue_is_empty() {
    let mut queue: *mut Queue = std::ptr::null_mut();

    queue = queue_new();
    let queue_box = unsafe { Box::from_raw(queue) };

    assert!(queue_is_empty(queue) != 0, "queue_is_empty(queue) should not be 0");

    queue_push_head(queue, unsafe { &mut variable1 as *mut libc::c_int as QueueValue });

    assert!(queue_is_empty(queue) == 0, "queue_is_empty(queue) should be 0");

    queue_pop_head(queue);

    assert!(queue_is_empty(queue) != 0, "queue_is_empty(queue) should not be 0");

    queue_push_tail(queue, unsafe { &mut variable1 as *mut libc::c_int as QueueValue });

    assert!(queue_is_empty(queue) == 0, "queue_is_empty(queue) should be 0");

    queue_pop_tail(queue);

    assert!(queue_is_empty(queue) != 0, "queue_is_empty(queue) should not be 0");

    queue = Box::into_raw(queue_box);
    queue_free(queue);
}
